﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ListAssert.cs" company="JDML Consulting Ltd.">
//   Copyright 2011 Photon Project - http://photon.codeplex.com
// </copyright>
// <summary>
//   Defines the ListAssert type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Photon.Testing
{
    using System.Collections.Generic;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    public class ListAssert
    {
        public static void AreEqual<T>(IList<T> expected, IList<T> actual)
        {
            if (ReferenceEquals(expected, actual))
            {
                return;
            }

            if (ReferenceEquals(expected, null) || ReferenceEquals(actual, null))
            {
                Assert.Fail(string.Empty);
            }

            // TODO: Move messages into resources
            Assert.AreEqual(expected.Count, actual.Count, "List differ in size.");
            for (var i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i], "Lists differ at index {0}.", i);
            }
        }
    }
}
